package de.geckocraft.GeckoEventBroadcaster.Main;

import de.geckocraft.GeckoEventBroadcaster.Commands.Events;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public final class Main extends JavaPlugin
{
  public static Plugin plugin;
  public static Main main;

  public void onEnable()
  {
    plugin = getServer().getPluginManager().getPlugin(getName());
    loadConfigs();
    commands();
    AutoBroadcast.autocast();
  }

  public void onDisable()
  {
  }

  public static void loadConfigs()
  {
    Template.loadConfig();
    MainConfig.loadConfig();
    EventList.loadConfig();
  }

  private void commands()
  {
    getCommand("event").setExecutor(new Events(this));
  }

  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
  {
    return false;
  }

  public static Plugin getPlugin()
  {
    Plugin p = plugin;
    return p;
  }

  public static Main getMain()
  {
    Main main = (Main)plugin;
    return main;
  }

  public static boolean isInteger(String string)
  {
    boolean returnWert = false;
    try
    {
      Integer.parseInt(string);
      returnWert = true;
    }
    catch (Exception e) {
      returnWert = false;
    }
    return returnWert;
  }
}